﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SAIN.Abastos.catalogo
{
    public partial class Measures : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                List<BE.Abastos.Measures> medidas = new List<BE.Abastos.Measures>();

                medidas = new BC.Abastos.MeasuresBC().Select(new BE.Abastos.Measures() { iMeasureId = -1, sMeasureName = string.Empty });

                this.gvMedidas.DataSource = medidas;

                this.gvMedidas.DataBind();
            }
            catch (Exception ex)
            {
                ExceptionsLogger.WriteLog(ex);
            }
        }

        protected void btnCrearMedida_Click(object sender, EventArgs e)
        {
            try
            {
                BE.Abastos.Measures medida = new BE.Abastos.Measures();
                BC.Abastos.MeasuresBC controler = new BC.Abastos.MeasuresBC();

                medida.sMeasureName = this.txtMedida.Text;

                controler.Create(medida);


                List<BE.Abastos.Measures> medidas = new List<BE.Abastos.Measures>();

                medidas = new BC.Abastos.MeasuresBC().Select(new BE.Abastos.Measures() { iMeasureId = -1, sMeasureName = string.Empty });

                this.gvMedidas.DataSource = medidas;

                this.gvMedidas.DataBind();

            }
            catch(Exception ex)
            {
                ExceptionsLogger.WriteLog(ex);
            }
        }
    }
}